﻿@model Associativy.Settings.AssociativyNodeLabelTypePartSettings
@{
    Script.Require("jQuery").AtFoot();
}
@using (Script.Foot())
{
    <script type="text/javascript">
        (function ($) {
            $.extend(true, {
                associativy: {
                    refreshLabels: function () {
                        $("#button\\.RefreshLabels").attr("disabled", "disabled");
                        var url = '@Url.Action("RefreshLabels", new { Controller = "AssociativyNodeLabelAdmin", Area = "Associativy", ContentType = Model.ContentType })';
                        var postData = { __RequestVerificationToken: "@Html.AntiForgeryTokenValueOrchard()" };
                        $.post(url, postData, function (response) {
                            window.location.reload();
                        });
                    }
                }
            });
        })(jQuery);
    </script>
}
<fieldset>
    @Html.LabelFor(m => m.DefaultLabelPattern, T("Pattern for generating labels"))
    @Html.TextBoxFor(m => m.DefaultLabelPattern, new { @class = "tokenized text medium" })
    @Html.ValidationMessageFor(m => m.DefaultLabelPattern)
</fieldset>
@Display.TokenHint()

<fieldset>
    <button type="button" id="button.RefreshLabels" name="button.RefreshLabels" value="UpdateLabels"
        onclick="$.associativy.refreshLabels(); return false;">@T("Refresh labels")</button>
    <span class="hint">@T("This will regenerate labels stored with content items for this content type, based on the token configuration provided here.")</span>
</fieldset>
